package com.tanhua.admin.controller;

import com.tanhua.admin.service.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.Map;


@RestController
@RequestMapping("/dashboard")
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;

    /**
     * 后台首页概要统计
     */
    @GetMapping("/summary")
    public ResponseEntity summary() throws ParseException {
        Map<String,Integer> map = dashboardService.summary();
        System.out.println(map);

        return ResponseEntity.ok(map);
    }
    /**
     * 新增、活跃用户、次日留存率
     */
    @GetMapping("/users")
    public ResponseEntity users(String type) {
        Map<String,Map> map = dashboardService.users(type);

        return ResponseEntity.ok(map);
    }
}
